﻿using DMSkin.WPF;
using MXComponent.Common.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SoftRegisterAPP
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : DMSkinSimpleWindow
    {
        private SoftRegister sregister = new SoftRegister();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.txtMachineCode.Text))
            {
                MessageBox.Show("机器码不能为空！");
                return;
            }
            try
            {
                this.txtLicence.Text = sregister.GetRNum(this.txtMachineCode.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Environment.Exit(0);
        }

        private void DMSkinSimpleWindow_Loaded(object sender, RoutedEventArgs e)
        {
            this.txtMachineCode.Focus();
        }
    }
}